package com.example.smartcitydemo.ui.subway.subway.fragment

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.viewModels
import com.example.smartcitydemo.R
import com.example.smartcitydemo.base.BaseFragment
import com.example.smartcitydemo.databinding.FragmentSubwayImageBinding
import com.example.smartcitydemo.ext.onLoad
import com.example.smartcitydemo.viewModel.SubwayViewModel.SubWayViewModel

/**
 * @PACKAGE_NAME: com.example.smartcitydemo.ui.subway.subway.fragment
 * @NAME: Caleb.F
 * @DATE: 2021/11/17 14:22
 * @Email: 1919796283@qq.com
 *自己实现缩放图、点击放大：
 * Android 事件分发、手势识别：
 * Android开发艺术探索
 *
 */
class SubwayImageFragment :
    BaseFragment<FragmentSubwayImageBinding>(R.layout.fragment_subway_image) {
    private val subWayViewModel: SubWayViewModel by viewModels()

    override fun initData() {
        subWayViewModel.getSubWayImage()
    }

    override fun initView(bindView: FragmentSubwayImageBinding, savedInstanceState: Bundle?) {
        bindView.subwayImageToolbar.tvContent.text = "地铁图片"
    }

    override fun addObservers(bindView: FragmentSubwayImageBinding) {
        subWayViewModel.subWayImageUrl.observe(viewLifecycleOwner) {
            Log.d(TAG, "addObservers: $it")
            bindView.ivSubwayImage.onLoad(it.data?.imgUrl)
        }
    }
}